#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int pip[2];

int main(int argc, char *argv[]) {
  pipe(pip);
  pid_t pid;
  pid = fork();
  if(pid > 0){
    close(pip[1]);
    wait(NULL);
    dup2(pip[0],STDIN_FILENO);

    execl("/bin/wc","wc","-w",NULL);
  }else if(pid == 0){
    close(pip[0]);
    dup2(pip[1],STDOUT_FILENO);
    execl("/bin/ls","ls",NULL);
    
  }

  return 0;
}
